﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using Google.Contacts;
using DataType;
using MyGDocsAddIn.TestProxy;

namespace MyGDocsAddIn
{
    public class RemoteApplication : MarshalByRefObject
    {
        private static RemoteApplication application = new RemoteApplication();
        internal delegate void LoginDelegate(System.Object obj);

        /// <summary>
        /// The server application will use this singleton to set this type public 
        /// for remoting
        /// </summary>
        internal static RemoteApplication Instance
        {
            get { return application; }
        }

        private RemoteApplication() { }

        /// <summary>
        /// The client application will work with an instance that will be 
        /// retrieved thru remoting
        /// </summary>
        /// <returns></returns>
        public static RemoteApplication GetRemoteInstance()
        {
            object obj = Activator.GetObject(typeof(RemoteApplication), "tcp://localhost:9999/RemoteApplication");
            return obj as RemoteApplication;
        }

        public void DoQuit()
        {
            Globals.ThisAddIn.Application.Quit();
        }
        
        public MyGDocsForm GetUiAccessPoint()
        {
            return Globals.ThisAddIn.m_MyGDocsForm;
        }

        public long Test1()
        {
            //return Globals.ThisAddIn.m_MyGDocsForm.ContactListBox.Items.Count;
            //return Globals.ThisAddIn.m_UIProxy.m_Form.ContactListBox.Items.Count;
            UIProxy a = Globals.ThisAddIn.m_UIProxy;
            return a.LookAtContactsCount();
        }

        public UIProxy GetUiProxyAccessPoint()
        {
            return Globals.ThisAddIn.m_UIProxy;
        }
    }
}
